# encoding:utf-8
# @author='dapeng',
# @version='1.0.0'
import requests
from bs4 import BeautifulSoup


def xinlang():
    url = 'https://s.weibo.com/top/summary'
    markup = requests.get(url=url).text
    soup = BeautifulSoup(markup, 'html5lib')
    tbody = soup.find('tbody')
    # html.parser解析HTML网页
    trs = soup.find_all("tr")
    list = []
    i = 0
    for tr in trs:
        if i > 1:
            list.append(tr.contents[1].text)
            list.append(' ')
            list.append(tr.contents[3].contents[1].text)
            list.append(' ')
            list.append("https://s.weibo.com/"+tr.contents[3].contents[1].attrs['href'])
            list.append('\r\n')
        i = i+1
    return ''.join(list)


def xinlang10():
    url = 'https://s.weibo.com/top/summary'
    markup = requests.get(url=url).text
    soup = BeautifulSoup(markup, 'html5lib')
    tbody = soup.find('tbody')
    # html.parser解析HTML网页
    trs = soup.find_all("tr")
    list = []
    i = 0
    for tr in trs:
        if i>12:
            break
        if i > 1:
            list.append(tr.contents[1].text)
            list.append(' ')
            list.append(tr.contents[3].contents[1].text)
            list.append(' ')
            list.append("https://s.weibo.com/"+tr.contents[3].contents[1].attrs['href'])
            list.append('\r\n')
        i = i+1
    return ''.join(list)